package com.zxc.flowSum;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class FlowSumRc extends Reducer<LongWritable, FlowSum, Text, FlowSum> {
    FlowSum v = new FlowSum();

    protected void reduce(Text key, Iterable<FlowSum> values, Reducer<LongWritable, FlowSum, Text, FlowSum>.Context context) throws IOException, InterruptedException {
        long up = 0;
        long low = 0;
        for (FlowSum value : values) {
            up += value.getUp();
            low += value.getLow();
        }
        v.setAll(up,low);
        // 写出
        context.write(key, v);
    }

}
